package com.bridgeintelligent.tag.webserver.security;

import com.bridgeintelligent.tag.user.mgmt.pojo.User;
import com.wayneleo.quickstart.framework.BaseResponse;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;
import java.util.Set;

@Getter
@Setter
public class LoginResponse extends BaseResponse {

    private int code;

    private Data data;

    private String msg;

    public LoginResponse() {
    }

    public LoginResponse(Data data) {
        this.data = data;
        setCode(0);
    }

    public LoginResponse(int code,String msg){
        this.code = code;
        this.msg = msg;
    }

    @Getter
    @Setter
    public static class Data {
        @ApiModelProperty("用户主键")
        private String userId;
        @ApiModelProperty("用户名")
        private String username;
        @ApiModelProperty("密码")
        private String password;
        @ApiModelProperty("姓名")
        private String name;
        @ApiModelProperty("手机号")
        private String userPhone;
        @ApiModelProperty("办公电话")
        private String officePhone;
        @ApiModelProperty("机构")
        private String institution;
        @ApiModelProperty("所属部门")
        private String department;
        @ApiModelProperty("角色id")
        private String roleId;
        @ApiModelProperty("操作时间")
        private String operateTime;
        @ApiModelProperty("是否有效:01表示有效,02表示无效")
        private String efftctiveSymbol;
        @ApiModelProperty("是否有效:01表示有效,02表示无效")
        private String roleName;
        @ApiModelProperty("是否有效:01表示有效,02表示无效")
        private String isEfftctive;
        @ApiModelProperty("权限集合")
        private Set<String> permissions;
        @ApiModelProperty("角色集合集合")
        private Map<String,String> roleMap;
        @ApiModelProperty("用户唯一标识")
        private String yuSid;

        public Data(User user, Set<String> permissions) {
            this.userId = user.getUserId();
            this.username = user.getUsername();
            this.password = user.getPassword();
            this.name = user.getName();
            this.userPhone = user.getUserPhone();
            this.officePhone = user.getOfficePhone();
            this.institution = user.getInstitution();
            this.department = user.getDepartment();
            this.roleId = user.getRoleId();
            this.operateTime = user.getOperateTime();
            this.efftctiveSymbol = user.getEfftctiveSymbol();
            this.roleName = user.getRoleName();
            this.isEfftctive = user.getIsEfftctive();
            this.permissions = permissions;
            this.roleMap = user.getRoleMap();
            this.yuSid = user.getYuSid();
        }
    }
}
